<template>
  <div class="custom-tab">
    <div
      v-for="item of tabs"
      @click="handleChange(item)"
      :key="item.name"
      class="tab-item"
      :class="{ active: item.name === activeName }"
    >
      <span>{{ item.label }}</span>
    </div>
  </div>
</template>

<script setup>
defineProps({
  tabs: {
    type: Array,
    default: () => [],
  },
  activeName: {
    type: String,
    default: "",
  },
});

const emits = defineEmits(["update:activeName"]);

function handleChange(item) {
  emits("update:activeName", item.name);
}
</script>

<style lang="scss" scoped>
.custom-tab {
  display: flex;
  .tab-item {
    position: relative;
    font-family: SourceHanSansCN-Bold;
    font-weight: 700;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    padding-bottom: 8px;
    margin: 0px 5px;
    &::after {
      position: absolute;
      content: "";
      width: 100%;
      height: 2px;
      background: transparent;
      bottom: 0px;
      left: 0px;
    }
    &.active {
      color: #ffffff;
      &::after {
        background: #087ef8;
      }
    }
  }
}
</style>
